package org.xxpay.mch.common.config;

import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.api.impl.WxMpServiceImpl;
import me.chanjar.weixin.mp.config.impl.WxMpDefaultConfigImpl;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

@Component
@ConfigurationProperties(prefix="config")
public class MainConfig {

	private String appId;

	private String appSecret;

	private String token;

	private String aesKey;

	private String downloadDemoPath;

	private String payTestMchId;

	@Bean
	public WxMpDefaultConfigImpl wxMpConfigStorage() {
		return getWxMpConfigStorage();
	}

	@Bean
	public WxMpService wxMpService() {
		WxMpService wxMpService = new WxMpServiceImpl();
		wxMpService.setWxMpConfigStorage(getWxMpConfigStorage());
		return wxMpService;
	}

	protected WxMpDefaultConfigImpl getWxMpConfigStorage() {
		WxMpDefaultConfigImpl configStorage = new WxMpDefaultConfigImpl();
		configStorage.setAppId(this.appId);
		configStorage.setSecret(this.appSecret);
		configStorage.setToken(this.token);
		configStorage.setAesKey(this.aesKey);
		return configStorage;

	}

	public String getAppId() {
		return appId;
	}

	public void setAppId(String appId) {
		this.appId = appId;
	}

	public String getAppSecret() {
		return appSecret;
	}

	public void setAppSecret(String appSecret) {
		this.appSecret = appSecret;
	}

	public String getToken() {
		return token;
	}

	public void setToken(String token) {
		this.token = token;
	}

	public String getAesKey() {
		return aesKey;
	}

	public void setAesKey(String aesKey) {
		this.aesKey = aesKey;
	}

	public String getDownloadDemoPath() {
		return downloadDemoPath;
	}

	public void setDownloadDemoPath(String downloadDemoPath) {
		this.downloadDemoPath = downloadDemoPath;
	}

	public String getPayTestMchId() { return payTestMchId; }

	public void setPayTestMchId(String payTestMchId) { this.payTestMchId = payTestMchId; }

}